package com.lhf.series.test.custmoerviewexample.view;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.lhf.series.test.custmoerviewexample.R;

/**
 * 组合控件
 * Created by lihf on 16/9/19.
 */
public class TitleView extends FrameLayout {

    private Button leftButton;
    private TextView titleView;

    public TitleView(Context context, AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater.from(context).inflate(R.layout.title_layout, this);
        titleView = (TextView) findViewById(R.id.tv_title);
        leftButton = (Button) findViewById(R.id.btn_back);
        leftButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((Activity)getContext()).finish();
            }
        });

    }

    public void setTitleView(String text){
        titleView.setText(text);
    }

    public void setLeftButtonText(String text){
        leftButton.setText(text);
    }

    public void setLeftButtonListener(OnClickListener listener){
        leftButton.setOnClickListener(listener);
    }



}
